package ${packageName};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ${BASE_PACKAGE}.model.dto.${tableInfo.className?cap_first}DTO;
import ${BASE_PACKAGE}.model.param.${tableInfo.className?cap_first}Param;
import ${BASE_PACKAGE}.service.${tableInfo.className?cap_first}Service;
import ${BASE_PACKAGE}.common.ResponseDTO;
import ${BASE_PACKAGE}.common.RequestDTO;
import com.umsin.base.model.dto.ResponseDTO;
import com.umsin.base.model.dto.RequestDTO;
import com.umsin.base.model.dto.PageDataDTO;
import java.util.List;
import ${BASE_PACKAGE}.model.po.${tableInfo.className?cap_first}Entity;


@RestController
@RequestMapping("/${tableInfo.className?uncap_first}")
public class ${tableInfo.className?cap_first}Controller {

    @Autowired
    private ${tableInfo.className?cap_first}Service ${tableInfo.className?uncap_first}Service;

    @PostMapping("/add")
    public ResponseDTO<${tableInfo.className?cap_first}Entity> add(@RequestBody RequestDTO<${tableInfo.className?cap_first}DTO> request) {
        ${tableInfo.className?cap_first}Entity result = ${tableInfo.className?uncap_first}Service.add(request.getData());
        return ResponseDTO.success(result);
    }

    @PostMapping("/modify")
    public ResponseDTO<Void> modify(@RequestBody RequestDTO<${tableInfo.className?cap_first}DTO> request) {
        ${tableInfo.className?uncap_first}Service.modify(request.getData());
        return ResponseDTO.success();
    }

    @PostMapping("/remove")
    public ResponseDTO<Void> remove(@RequestBody RequestDTO<Long> request) {
        ${tableInfo.className?uncap_first}Service.remove(request.getData());
        return ResponseDTO.success();
    }

    @PostMapping("/page")
    public ResponseDTO<PageDataDTO<${tableInfo.className?cap_first}DTO>> page(@RequestBody RequestDTO<${tableInfo.className?cap_first}Param> request) {
        PageDataDTO<${tableInfo.className?cap_first}DTO> result = ${tableInfo.className?uncap_first}Service.page(request.getData());
        return ResponseDTO.success(result);
    }

    @PostMapping("/list")
    public ResponseDTO<List<${tableInfo.className?cap_first}DTO>> list(@RequestBody RequestDTO<${tableInfo.className?cap_first}Param> request) {
        List<${tableInfo.className?cap_first}DTO> result = ${tableInfo.className?uncap_first}Service.list(request.getData());
        return ResponseDTO.success(result);
    }
}